package corej.course.basic;

public class TestTeam {
    static int number;

    static int[] teams;

    public static void main(String[] args) {
        /*
           * Ҫ���û����������ж��ǲ���ż��
           */
        number = Integer.parseInt(args[0]);
        if (number < 0 || number % 2 == 1) {
            System.out.println("Error!");
            System.exit(0);
        }
        /*
           * �������鲢�ҳ�ʼ��
           */
        teams = new int[number];
        for (int i = 0; i < teams.length; i++) {
            teams[i] = i + 1;
        }

        for (int i = 1; i < number; i++) {
            System.out.println("Round " + i);
            print();
            nextRound();
        }

    }

    // �����ӡÿ�ֵĶ�����ʽ
    static void print() {
        for (int i = 0; i < number / 2; i++) {
            System.out.print(teams[i] + "---" + teams[number - 1 - i] + "  ");
        }
        System.out.println();
    }

    // ��������Ԫ�ص��ֻ�
    static void nextRound() {
        int temp = teams[number - 1];
        for (int i = number - 1; i > 1; i--) {
            teams[i] = teams[i - 1];
        }
        teams[1] = temp;
    }
}